package com.imooc.user.mapper;

import com.imooc.thrift.user.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author liuhuan
 * @date 2018/11/1 15:42
 * @description
 */
public interface UserMapper {
    /**
     * find user by id
     * @param id
     * @return
     */
    @Select("select id ,username,password,real_name realName," +
            "mobile,email from pe_user where id = #{id}")
    UserInfo getUserById(@Param("id") int id);

    /**
     * find user by username
     * @param username
     * @return
     */
    @Select("select id ,username,password,real_name realName," +
            "mobile,email from pe_user where username = #{username}")
    UserInfo getUserByName(@Param("username") String username);

    /**
     * regiser user
     * @param userInfo
     */
    @Insert("insert into pe_user (username,password,real_name ," +
            "mobile,email ) values(#{u.username},#{u.password},#{u.realName}," +
            "#{u.mobile},#{u.email})")
    void regiserUser(@Param("u") UserInfo userInfo);
}
